import { baseUrl } from "./config.js"
export function xinwenpd() {
	return uni.request({
		// url: `http://10.83.232.158:7062/api/Chanel`,
		url: `${baseUrl}/Chanel`,
		// url: `http://10.83.232.158:7062/api/Chanel`,
		// header:{
		// 	'Authorization':`APPCODE ${APPCODE}`
		// },
		method: 'GET'
	})
}
export function xinwenpdid() {
	return uni.request({
		// url: `http://10.83.232.158:7062/api/Chanel/Getid`,
		url: `${baseUrl}/Chanel/Getid`,
		// url: `http://10.83.232.158:7062/api/Chanel/Getid`,
		// header:{
		// 	'Authorization':`APPCODE ${APPCODE}`
		// },
		method: 'GET'
	})
}
export function postpd(title) {
	uni.request({
		// url: `http://10.83.232.158:7062/api/Chanel`,
		url: `${baseUrl}/Chanel`,
		// url: `http://10.83.232.158:7062/api/Chanel`,
		method: 'POST',
		data: {
			id: '',
			title: title
		},
		success: res => {
		// console.log("ok")
		},
		fail: () => {},
		complete: () => {}
	});
}
export function deletepd(id) {
	uni.request({
		// url: `http://10.83.232.158:7062/api/Chanel/${id}`,
		url: `${baseUrl}/Chanel/${id}`,
		// url: `http://10.83.232.158:7062/api/Chanel/${id}`,
		method: 'DELETE',
		success: res => {
			console.log(res)
		},
		fail: () => {},
		complete: () => {}
	});
}
export function putpd(id, title) {
	uni.request({
		// url: `http://10.83.232.158:7062/api/Chanel/${id}`,
		url: `${baseUrl}/Chanel/${id}`,
		// url: `http://10.83.232.158:7062/api/Chanel/${id}`,
		method: 'PUT',
		data: {
			id: id,
			title: title
		},
		success: res => {
		},
		fail: () => {},
		complete: () => {}
	});
}

export function titlesousuo(title) {
	return uni.request({
		// url: `http://10.83.232.158:7062/api/Chanel/title?title=${title}`,
		url: `${baseUrl}/Chanel/title?title=${title}`,
		// url: `http://10.83.232.158:7062/api/Chanel/title?title=${title}`,
		method: 'GET'
	});
}

export function xinwenlist(channel, num) {
	return uni.request({
		// url: `http://10.83.232.158:7062/api/News/Getchannel?channel=${channel}&num=${num}`,
		url: `${baseUrl}/News/Getchannel?channel=${channel}&num=${num}`,
		// url: `http://10.83.232.158:7062/api/News/Getchannel?channel=${channel}&num=${num}`,
		// header:{
		// 	'Authorization':`APPCODE ${APPCODE}`
		// },
		method: 'GET'
	})
}




export function xinwennr() {
	return uni.request({
		// url: `http://10.83.232.158:7062/api/News`,
		url: `${baseUrl}/News`,
		// url: `http://10.83.232.158:7062/api/News`,
		// header:{
		// 	'Authorization':`APPCODE ${APPCODE}`
		// },
		method: 'GET',
		success(res) {
			// console.log(res.channel)
		}
	})
}

export function xinwenpost(newchannel,newtitle,newcontent,newtime)
{
	return uni.request({
		url:`${baseUrl}/News`,
		method:"POST",
		data:
		{
			id:'',
			channel:newchannel,
			num:'',
			title:newtitle,
			src:"",
			url: "",
			weburl: "",
			pic: "",
			time:newtime,
			content:newcontent,
			category:""
			

			
		},
		success: () => {},
		fail: () => {},
		complete: () => {}
	})
}

export function xwdelete (id){
	uni.request({
		// url:`http://10.83.232.158:7062/api/News/${id}`,
		url:`${baseUrl}/News/${id}`,
		// url:`http://10.83.232.158:7062/api/News/${id}`,
		method:'DELETE',
		success: () => {},
		fail: () => {},
		complete: () => {}
	});
}


export function xinwendenglu(id,mima) {
	var user = {"username":id,"password":mima}
	return uni.request({
		url: `http://10.83.232.158:7062/Users`,
		method: 'POST',
		header:{
			'Content-Type':'application/json'
		},
		data: user
	})
}
